package com.wpp.basespringboot;

import com.wpp.basespringboot.dao.ResumeDao;
import com.wpp.basespringboot.po.ResumePO;
import com.wpp.basespringboot.po.ResumePOJO;
import com.wpp.basespringboot.reposityory.ResumeMapper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.List;

/**
 * @author wpp25
 * @date 2021/6/21 21:58
 * @description：
 */
@SpringBootApplication
public class MongoDBApplication {

    public static void main(String[] args) {
        ApplicationContext applicationContext = SpringApplication.run(MongoDBApplication.class, args);

        findByRepositoryTest(applicationContext);

        System.out.println("---------------");
        findByTemplateTest(applicationContext);
    }

    private static void findByRepositoryTest(ApplicationContext applicationContext) {
        ResumeMapper resumeMapper = applicationContext.getBean(ResumeMapper.class);

        List<ResumePOJO> all = resumeMapper.findAll();
        for (ResumePOJO resumePOJO : all) {
            System.out.println(resumePOJO);
        }
        System.out.println("========================");
        System.out.println(resumeMapper.findByNameEquals("fuli"));
        System.out.println(resumeMapper.findByNameAndExpectSalary("fuli",28000.00));
    }

    private static void findByTemplateTest(ApplicationContext applicationContext) {
        ResumeDao resumeDao = applicationContext.getBean("resumeDao", ResumeDao.class);

        List<ResumePO> bj = resumeDao.queryBySalaryAndCity(17000, "bj");
        for (ResumePO resumePO : bj) {
            System.out.println(resumePO);
        }
    }
}
